package com.example.shopp_2301.welfg

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.base.mvvm.BaseFragment
import com.example.base.mvvm.BaseViewFragment
import com.example.shopp_2301.R
import com.example.shopp_2301.adapter.FenAdapter
import com.example.shopp_2301.databinding.FragmentBlank2Binding
import com.example.shopp_2301.room.AppDbUtils


class BlankFragment2 : BaseViewFragment<FragmentBlank2Binding>() {
    lateinit var fenAdapter: FenAdapter
    override fun initView() {
        fenAdapter = FenAdapter()
        binding.rv.adapter = fenAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)

        queryAll()//封成方法，方便其他地方调用


    }

    public fun queryAll() {
        //请求全部
        val query = AppDbUtils.getDb().getFenDao().queryType(1)
        fenAdapter.data.clear()
        fenAdapter.data.addAll(query)
        fenAdapter.notifyDataSetChanged()
    }

    override fun initData() {

    }

    override fun getLayout(): Int {
        return R.layout.fragment_blank2
    }
}